/*
 * loadExistingStorage.java
 *
 * Created on March 26, 2007, 7:11 AM
 *
 */

package edu.byu.isys413.actions;

import javax.servlet.http.*;
import edu.byu.isys413.group1E.data.*;
import edu.byu.isys413.group1E.handlers.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

/** This action responds to a request from the UI to view the existing items in 
 * the member's backup storage.
 *
 * @author Travis Kulbeth
 */
public class loadExistingStorage implements edu.byu.isys413.web.Action {
    
    /** Creates a new instance of loadCatalog */
    public loadExistingStorage() {
    }
    
    /** 
     *Processes method loads in the Backup Data the customer already has so that it can be displayed to the user.
     *
     * @return String the name of the jsp to call
     * @param request contains the HttpServletRequest data
     * @param response contains the HttpServletResponse data
     * @throws java.lang.Exception to catch any errors and forward them to the ui level
     */
    public String process(HttpServletRequest request, HttpServletResponse response) throws Exception {
        
        
        HttpSession session = request.getSession();
        CustomerBO cust = (CustomerBO)session.getAttribute("customer");
        TransactionDAO TXDAO = TransactionDAO.getInstance();
        
        ArrayList<BackupDataBO> bkDataList = BackupDataHandler.getInstance().readListByCust(cust);
        
        ArrayList<String> iconList = BackupDataHandler.getInstance().getIcons(bkDataList);
        
        request.setAttribute("bkDataList", bkDataList);
        request.setAttribute("iconList", iconList);
        
        return "storage.jsp";
    }
    
}
